﻿

let Table = {
    tid: '',
    status: 0,
    type: '',
    number: '',
    sumber: 0
};

let Nums = [{
    num: 1
},
{
    num: 2
},
{
    num: 3
},
{
    num: 4
},
{
    num: 5
},
{
    num: 6
},
{
    num: 7
},
{
    num: 9
}, {
    num: 10
}];

Peng_Select.CreateElement('Num_Select', Nums, 'num', (res) => {
    Table.sumber = res.num;
}, "num", 5);


$.get("/Table/GetTableType").then(res => {
    Peng_Select.CreateElement('StatusSelect', res.data, 'name', (res) => {
        Table.type = res.id;
    });
});

let AddTable = document.querySelector("#AddTable");
AddTable.onclick = function () {
    let input = document.querySelector("#Tnumber");
    Table.number = input.value;

    if (input.value != "") {
        $.post("/Table/addtables", Table).then(res => {
            if (res.code == 0) {
                Peng.Show(res.message, { type: "Success" });
                Peng.confirm({ title: '添加成功', content: '返回餐桌管理查看吗?' }, (E) => {
                    Peng.closeconfirm(E);
                    window.location.href = "/index/index";
                });
            } else {
                Peng.Show(res.message, { type: "Danger" });
            }

        });
    } else {
        Peng.Show('内容不能为空', { type: "Danger" });
        input.focus();
    }


}


